﻿<!DOCTYPE html>
<html>
<%@ include file="/commons/head.jsp" %>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <%@ include file="/commons/left.jsp" %>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                角色信息
            </h1>
        </section>
        <div class="content">
            <div class="row">
                <div class="col-md-9">
                    <div class="box box-primary" style="overflow:hidden">
                        <form id="postForm" class="form-horizontal" autocomplete="off">
                            <input type="hidden" name="Id" value="${entity.id}">
                            <div class="box-body" style="padding-top:30px">
                                <div class="form-group">
                                    <label for="inputRoleName" class="col-sm-2 control-label">角色名称</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputRoleName"
                                               name="roleName" value="${entity.roleName}" placeholder="请输入角色名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputRoleCode" class="col-sm-2 control-label">角色代码</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputRoleCode"
                                               name="roleCode" value="${entity.roleCode}" placeholder="请输入角色代码">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="remark" class="col-sm-2 control-label">内容摘要</label>
                                    <div class="col-sm-5">
                                        <textarea class="form-control" rows="3" autocomplete="off" id="remark"
                                                  name="remark" placeholder="Enter ...">${entity.remark}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="box-footer">
                                <div class="col-sm-2"></div>
                                <button type="button" class="btn btn-info" onclick="submitForm()">提交</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@ include file="/commons/script.jsp" %>
    <script type="text/javascript">
        function submitForm() {
            var id = $('#postForm').find('input[name=Id]').val();
            var url = null;
            if (id == null || id == "") {
                url = "${ctx}/role/saveRole?action=add";
            } else {
                url = "${ctx}/role/saveRole?action=update";
            }
            $.ajax({
                cache: false,
                type: "post",
                url: url,
                data: $('#postForm').serialize(),// formid
                error: function () {
                    alert("系统异常");
                },
                success: function (data) {
                    if (data !== null) {
                        if (data == 0) {
                            //修改失败
                            alert('失败');
                            window.location.href="${ctx}/role/listRole";
                        } else {
                            //添加/修改成功
                            alert('成功');
                        }
                    }
                }
            });
        }
    </script>
</body>
</html>
